package com.myidis.entity;

import java.util.ArrayList;
import java.util.List;

public class TimeSequence {
	private int quota;
	private ArrayList<String> dates;
	private ArrayList<Double> values;
	private int  QuotaDataType;
	private int frequency;



	public int getQuota() {
		return quota;
	}

	public void setQuota(int quota) {
		this.quota = quota;
	}

	public int getFrequency() {
		return frequency;
	}

	public void setFrequency(int frequency) {
		this.frequency = frequency;
	}

	public ArrayList<String> getDates() {
		return dates;
	}
	public void setDates(ArrayList<String> date) {
		this.dates = date;
	}
	public ArrayList<Double> getValues() {
		return values;
	}
	public void setValues(ArrayList<Double> value) {
		this.values = value;
	}
	/// <summary>
    /// 得到开始日期
    /// </summary>
    /// <returns></returns>
    public String getStartDateString()
    {
        if (dates == null || dates.size() < 1)
            return null;
        else
            return dates.get(0);
    }
    /// <summary>
    /// 得到最后日期
    /// </summary>
    /// <returns></returns>
    public String getEndDateString()
    {
        if (dates == null || dates.size() < 1)
            return null;
        else

            return dates.get(dates.size() - 1);
    }

	public TimeSequence() {
		this.quota = 1;
		this.dates = new ArrayList<String>();
		this.values = new ArrayList<Double>();
	}

	public TimeSequence(List<QuotaData> datas) {
		this();
		this.quota = datas.size() > 0 ? datas.get(0).getQuota() : 1;
		this.frequency = datas.size() > 0 ? datas.get(0).getFrequency() : 1;
		for (QuotaData data:datas) {
			dates.add(data.getTime());
			values.add((double) data.getValue());
		}
	}



	public int getQuotaDataType() {
		return QuotaDataType;
	}
	public void setQuotaDataType(int quotaDataType) {
		QuotaDataType = quotaDataType;
	}
	public boolean AddValue(String dateString, Double value) {
//		if (_valueDictionary.ContainsKey(dateString))
//			return false;
//		_dateList.Add(dateString);
//		_valueList.Add(value);
//		_valueDictionary.Add(dateString, value);
		return true;
	}
    
	public boolean SetTimeSequenceValue(ArrayList<String> dateList, ArrayList<Double> valueList)
    {
        if (dateList == null || valueList == null || dateList.size() != valueList.size())
            return false;
        for (int i = 0; i < dateList.size(); i++)
        {
            AddValue(dateList.get(i), valueList.get(i));
        }

        return true;
    }


	public void Rebuild(List<QuotaData> datas) {
		this.quota = datas.size() > 0 ? datas.get(0).getQuota() : 1;
		this.frequency = datas.size() > 0 ? datas.get(0).getFrequency() : 1;
		for (QuotaData data : datas) {
			dates.add(data.getTime());
			values.add((double) data.getValue());
		}
	}
}
